package cn.tedu;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;

/**
 * @author liyuehui
 * @time 2024/7/8 20:08
 */
public class CasDemo {
    public static void main(String[] args) {
        /*AtomicInteger atomicInteger = new AtomicInteger(1);
        boolean b = atomicInteger.compareAndSet(1, 2);
        System.out.println(b);
        boolean b1 = atomicInteger.compareAndSet(1, 2);
        System.out.println(b1);*/
        /*Student student = new Student("张三", 18, "男");
        AtomicReference<Student> atomicReference = new AtomicReference<>(student);
        boolean b = atomicReference.compareAndSet(student, new Student("李四", 18, "女"));
        System.out.println(b);
        boolean b2 = atomicReference.compareAndSet(student, new Student("李四", 18, "女"));
        System.out.println(b2);
        System.out.println(atomicReference);*/
    }
}
